/*
 * @Description: 
 * @Author: sheng.xia
 * @Date: 2021-12-08 15:31:14
 */
import { Form, Button, Card, InputNumber, Switch, message } from 'antd';
import store from '@/store'
export default function My() {
  const [userState, userDispatchers] = store.useModel('user');
  const onFinish = (values: any) => {
    message.success('保存成功')
    userDispatchers.update(values)
  };
  return (
    <div>
      <Card title="番茄钟设置" style={{ width: 500 }}>
        <Form
          name="basic"
          labelCol={{ span: 8 }}
          wrapperCol={{ span: 16 }}
          initialValues={userState}
          onFinish={onFinish}
          autoComplete="off"
        >
          <Form.Item
            label="专注时长"
            name="workTime"
            rules={[{ required: true, message: '请输入' }]}
          >
            <InputNumber min={1} max={100} defaultValue={25} />
          </Form.Item>
          <Form.Item
            label="短时休息"
            name="shortRest"
            rules={[{ required: true, message: '请输入' }]}
          >
            <InputNumber min={1} max={100} defaultValue={5} />
          </Form.Item>
          <Form.Item
            label="长时休息"
            name="longRest"
            rules={[{ required: true, message: '请输入' }]}
          >
            <InputNumber min={1} max={100} defaultValue={15} />
          </Form.Item>
          <Form.Item
            label="长时间间隔"
            name="longInterval"
            rules={[{ required: true, message: '请输入' }]}
          >
            <InputNumber min={1} max={20} defaultValue={4} addonAfter={<span>个番茄</span>} />
          </Form.Item>

          <Form.Item
            label="禁用休息"
            name="disableRest"
          >
            <Switch />
          </Form.Item>
          <Form.Item
            label="自动开始休息"
            name="autoRest"
          >
            <Switch />
          </Form.Item>
          <Form.Item
            label="自动下次专注"
            name="autoFoucs"
          >
            <Switch />
          </Form.Item>
          <Form.Item wrapperCol={{ offset: 8, span: 16 }}>
            <Button type="primary" htmlType="submit">
              保存
            </Button>
          </Form.Item>
        </Form>
      </Card>

    </div>
  );
}
